package com.example.touch.domain;

import android.app.Activity;
import android.content.Context;
import android.os.Vibrator;

import com.example.touch.communication.entities.Vibrate;

/**
*
* @author pla
*/
public class VibrationAction extends AbstractActivityAction<Vibrate>
{
	public VibrationAction(Activity activity, Vibrate action) 
	{
		super(activity, action);
	}

	@Override
	protected void executeAction() 
	{
		Activity activity = getActivity();
		Vibrate vAction = getAction();
		
		Vibrator v = (Vibrator)(activity.getSystemService(Context.VIBRATOR_SERVICE));
		long duration = vAction.getDuration() != null && vAction.getDuration().equalsIgnoreCase("long") ? 1500 : 500;
		
		v.vibrate(duration);
	}
}
